/**
 * @file binary_search_tree.cpp
 * @author 逆流 (1171267147@qq.com)
 * @brief
 * @version 0.1
 * @date 2024-10-15
 *
 * @copyright Copyright (c) 2024
 */

#include <gtest/gtest.h>

#include <iostream>

#include "stl/container/binary_search_tree.hpp"

using stl::BinarySearchTree;

TEST(BinarySearchTree, Basic) {
    BinarySearchTree<int> tree;

    auto temp = std::chrono::system_clock::now().time_since_epoch().count();
    auto seed = static_cast<unsigned int>(temp);

    for (int i = 0; i < 8; ++i) {
        auto val = rand_r(&seed) % 100;
        std::cout << val << " ";
        tree.Push(val);
    }
    std::cout << "\n";

    EXPECT_EQ(tree.size(), 8);

    std::function<void(int)> print = [](int data) {
        std::cout << data << " ";
    };

    tree.Preorder(print);
    std::cout << "\n";

    tree.Inorder(print);
    std::cout << "\n";

    tree.Postorder(print);
    std::cout << "\n";
}
